package com.slz3.business.module.configManagement.conShareManage.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.functions.Add;
import com.slz3.business.frame.functions.Modify;
import com.slz3.business.frame.module.DomainEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

import java.time.LocalDate;
import java.util.UUID;

import static javax.persistence.EnumType.STRING;

@MappedSuperclass
@Data
@EqualsAndHashCode(callSuper = false)
public class ConShareManageEntity extends DomainEntity {

    /**
     * 编号
     */
    @Column(length = 80)
    @Length(min = 1, max = 80, message = "ser2 必须非空并且不超过 80 个字符!", groups = {Add.class, Modify.class})
    private String serNum;

    /**
     * 备注
     */
    @Basic(fetch = FetchType.LAZY)
    @Type(type = "text")
    private String serMemo;

    /**
     * 审核状态
     */
    @Enumerated(STRING)
    @NotNull(message = "serAudit 必须非空!", groups = {Add.class})
    @Null(message = "serAudit 必须为空!", groups = {Modify.class})
    private AuditFlag serAudit;

    /**
     * 启用状态
     */
    @Enumerated(STRING)
    @NotNull(message = "serUsing 必须非空!", groups = {Add.class})
    @Null(message = "serUsing 必须为空!", groups = {Modify.class})
    private UsingFlag serUsing;

    /**
     * 标签
     */
    private String serLabels;

    /**
     * 文件 url 地址
     */
    private String serFileUrl;

    /**
     * 富文本编辑器内容
     */
    @Basic(fetch = FetchType.LAZY)
    @Column(columnDefinition = "TEXT")
    private String serEditorContent;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate serInputGroupData;


    /**
     * 分享类别
     */
    @NotNull(message = "分享类别不能为空",groups ={Add.class,Modify.class})
    private ShareType serShareType;

    /**
     * 关联外键
     */
    @NotNull(message = "分享关联外键不能为空",groups = {Add.class,Modify.class})
    private UUID fkUUID;

    /**
     * 分享外键名称
     */
    private String serFkName;


    /**
     * 分享名称
     */
    private String serShareName;

    /**
     * 分享标题
     */
    private String serTitle;

    private Integer serShareNum;


}
